<?php

/**
 * 后台管理员管理
 */
class adminListModel
{

    public function __construct(& $base)
    {
        $this->base = $base;
        $this->db = & $this->base->db;
        $this->redis = & $this->base->redis;
    }
    
    /**
     * 判断指定用户是否有后台权限
     * @param int $hupuUid
     * @return array
     */
    public function isAdminByHupuUid($hupuUid)
    {
        return $this->getRowByHupuUid($hupuUid);
    }

    /**
     * 更新单条管理员信息
     * @param array $data
     * @return boolean
     */
    public function update(array $data = array())
    {
        return $this->db->updateRowTable('r_admin_list', $data);
    }

    /**
     * 添加一条管理员信息
     * @param array $data
     * @return integer
     */
    public function insert(array $data = array())
    {
        return $this->db->insertRowTable('r_admin_list', $data);
    }

    /**
     * 通过虎扑用户ID获取单个管理员信息
     * @param int $hupuUid
     * @return array
     */
    public function getRowByHupuUid($hupuUid)
    {
        return $this->db->getRowTable('r_admin_list', array(), "hupu_uid='{$hupuUid}'");
    }

    /**
     * 通过虎扑用户ID删除单条管理员信息
     * @param int $hupuUid
     * @return boolean
     */
    public function deleteRowByHupuUid($hupuUid)
    {
        return $this->db->delDataTable('r_admin_list', "hupu_uid='{$hupuUid}'");
    }

    /**
     * 获取管理员列表
     * @param int $num
     * @return array
     */
    public function getList($num = 100)
    {
        $adminList = array();

        $sql = "select * from r_admin_list limit {$num}";
        $adminList = $this->db->getAll($sql);

        return $adminList;
    }
}

  
